<?php
class Grade{

	public function getGrade(){
		$DB = new DB();
		$sql = "SELECT * FROM grade";
		return $DB->fetchAll($sql);
	}
	
	public function addGrade($title){
		$DB = new DB();
		$sql = "INSERT INTO `grade` VALUES (:id,:title)";
		$field = array(':id' => '',
					   ':title' => $title
					  );	
		return $DB->updateDB($sql,$field);			
	}
	
	public function getGradeById($id){
		$DB = new DB();
		$sql = "SELECT * from grade where id='$id'";
		return $DB->fetchRow($sql);
		
	}
	
	public function editGrade($id,$title){
		$DB = new DB();
		$sql = "UPDATE `grade` set title=? where id='$id'";
		$field = array($title);
		return $DB->updateDB($sql,$field);	
	}
	
	public function delGrade($id){
		global $db;
		$sql = "delete from `grade` where id='$id'";
		return $db->query($sql);		
	}
}
?>